function oAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
  		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function xmlhttp(){
		var xmlhttp;
		try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
		catch(e){
			try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
			catch(e){
				try{xmlhttp = new XMLHttpRequest();}
				catch(e){
					xmlhttp = false;
				}
			}
		}
		if (!xmlhttp) 
				return null;
			else
				return xmlhttp;
	}

function buscar(){
		var query = document.getElementById('q').value;
		var query2 = document.getElementById('op1').checked;
		var query3 = document.getElementById('op2').checked;
		var A = document.getElementById('resultados');
		var C = document.getElementById('resultados2');
		var B = document.getElementById('loading');
		var ajax = xmlhttp();

		ajax.onreadystatechange=function(){
				if(ajax.readyState==1){
						B.innerHTML = "<img src='img/loading.gif' alg='Cargando...'> <span style=\"color:#999\">Por favor espere...</span>";
					}
				if(ajax.readyState==4){
						A.innerHTML = ajax.responseText;
						B.innerHTML = "";
						C.innerHTML = "";
					}
			}
		ajax.open("GET","busqueda.php?q="+encodeURIComponent(query)+"&op1="+encodeURIComponent(query2)+"&op2="+encodeURIComponent(query3),true);
		ajax.send(null);
		return false;
	}
	
function detalle_activo(id_trabajador,cedula,serv){
		var id_trabaja= id_trabajador;
		var varcedula= cedula;
		var varserv= serv;
		var A = document.getElementById('resultados2');
		var B = document.getElementById('loading');
		var ajax = xmlhttp();
		ajax.onreadystatechange=function(){
				if(ajax.readyState==1){
						B.innerHTML = "<img src='img/loading.gif' alg='Cargando...'> <span style=\"color:#999\">Por favor espere...</span>";
					}
				if(ajax.readyState==4){
						A.innerHTML = ajax.responseText;
						B.innerHTML = "";
					}
			}
		ajax.open("GET","detalle_activo.php?cedula="+encodeURIComponent(varcedula)+"&id_trabajador="+encodeURIComponent(id_trabajador)+"&serv="+encodeURIComponent(varserv),true);
		ajax.send(null);
		return false;
	}
	
function detalle_egresado(id_trabajador,cedula,serv){
		var id_trabaja= id_trabajador;
		var varcedula= cedula;
		var varserv= serv;
		var A = document.getElementById('resultados2');
		var B = document.getElementById('loading');
		var ajax = xmlhttp();
		ajax.onreadystatechange=function(){
				if(ajax.readyState==1){
						B.innerHTML = "<img src='img/loading.gif' alg='Cargando...'> <span style=\"color:#999\">Por favor espere...</span>";
					}
				if(ajax.readyState==4){
						A.innerHTML = ajax.responseText;
						B.innerHTML = "";
					}
			}
		ajax.open("GET","detalle_egresado.php?cedula="+encodeURIComponent(varcedula)+"&id_trabajador="+encodeURIComponent(id_trabajador)+"&serv="+encodeURIComponent(varserv),true);
		ajax.send(null);
		return false;
	}